// DlgMarkBadPixel.cpp : implementation file
//

#include "stdafx.h"
#include "HubImage.h"
#include "DlgMarkBadPixel.h"


// DlgMarkBadPixel dialog

IMPLEMENT_DYNAMIC(DlgMarkBadPixel, CDialog)

DlgMarkBadPixel::DlgMarkBadPixel(CWnd* pParent /*=NULL*/)
	: CDialog(DlgMarkBadPixel::IDD, pParent)
{

}

DlgMarkBadPixel::~DlgMarkBadPixel()
{
}

void DlgMarkBadPixel::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(DlgMarkBadPixel, CDialog)
	ON_BN_CLICKED(ID_BUT_GetBadPixel, &DlgMarkBadPixel::OnBnClickedButGetbadpixel)
	ON_BN_CLICKED(ID_BUT_SetBadPixel, &DlgMarkBadPixel::OnBnClickedButSetbadpixel)
	ON_BN_CLICKED(ID_BUT_SaveToBadPixelFile, &DlgMarkBadPixel::OnBnClickedButSavetobadpixelfile)
END_MESSAGE_MAP()


// DlgMarkBadPixel message handlers

BOOL DlgMarkBadPixel::OnInitDialog()
{
	CDialog::OnInitDialog();

	theApp.SetDialogString(this, IDD);
	// TODO:  Add extra initialization here

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}

void DlgMarkBadPixel::LoadPixelFile()
{
    SetDlgItemText(IDC_EDIT_BadPixelFile,g_SysConfigParam.szBadPixelFile);
}

void DlgMarkBadPixel::OnBnClickedButGetbadpixel()
{
	int x = GetDlgItemInt(IDC_EDIT_MarkBadPixelX);
	int y = GetDlgItemInt(IDC_EDIT_MarkBadPixelY);
	DWORD dwValue = 0;
	g_HubCap.GetBadPixelValue(x,y,dwValue);
	SetDlgItemInt(IDC_EDIT_MarkBadPixelV,dwValue);
}

void DlgMarkBadPixel::OnBnClickedButSetbadpixel()
{
	int x = GetDlgItemInt(IDC_EDIT_MarkBadPixelX);
	int y = GetDlgItemInt(IDC_EDIT_MarkBadPixelY);

	DWORD dwValue = GetDlgItemInt(IDC_EDIT_MarkBadPixelV);
	g_HubCap.SetBadPixelValue(x,y,dwValue);
}

void DlgMarkBadPixel::OnBnClickedButSavetobadpixelfile()
{
	g_HubCap.SaveBadPixelReviseFile( g_SysConfigParam.szBadPixelFile );
}
